package com.lagou.dao.impI;

import com.lagou.dao.AccountDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

/**
 * @Author wsl
 * @Date 2021/11/14 20:18
 * @Project_Name jdbc_spring
 */
@Repository
public class AccountDaoImpI implements AccountDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    //减钱：转出操作
    public void out(String outUser, Double money) {
        String sql = "update account set money = money - ? where name = ?";
        jdbcTemplate.update(sql,money,outUser);
    }

    //加钱：转入操作
    public void in(String inUser, Double money) {
        String sql = "update account set money = money + ? where name = ?";
        jdbcTemplate.update(sql,money,inUser);
    }
}
